n = int(input())

def f(n):
    s = str(n)
    
    if len(set(s)) == len(s):
        return True
    else:
        return False

for i in range(n+1,10000):
    if f(i):
        print(i)
        break
